package com.ruoyi.education.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.education.domain.Indicator;
import com.ruoyi.education.service.IIndicatorService;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 指标信息,指标表Controller
 * 
 * @author yxy
 * @date 2024-10-19
 */
@RestController
@RequestMapping("/indicator/indicator")
public class IndicatorController extends BaseController
{
    @Autowired
    private IIndicatorService indicatorService;

    /**
     * 查询指标信息列表
     */

    @Anonymous
    @GetMapping("/list")
    public AjaxResult list(Indicator indicator)
    {
        List<Indicator> list = indicatorService.selectIndicatorList(indicator);
        return success(list);
    }

    /**
     * 导出指标信息列表
     */
    @PreAuthorize("@ss.hasPermi('indicator:indicator:export')")
    @Log(title = "指标信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Indicator indicator)
    {
        List<Indicator> list = indicatorService.selectIndicatorList(indicator);
        ExcelUtil<Indicator> util = new ExcelUtil<Indicator>(Indicator.class);
        util.exportExcel(response, list, "指标信息数据");
    }

    /**
     * 获取指标信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('indicator:indicator:query')")
    @GetMapping(value = "/{indicatorId}")
    public AjaxResult getInfo(@PathVariable("indicatorId") Long indicatorId)
    {
        return success(indicatorService.selectIndicatorByIndicatorId(indicatorId));
    }

    /**
     * 新增指标信息
     */
    @PreAuthorize("@ss.hasPermi('indicator:indicator:add')")
    @Log(title = "指标信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Indicator indicator)
    {
        return toAjax(indicatorService.insertIndicator(indicator));
    }

    /**
     * 修改指标信息
     */
    @PreAuthorize("@ss.hasPermi('indicator:indicator:edit')")
    @Log(title = "指标信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Indicator indicator)
    {
        return toAjax(indicatorService.updateIndicator(indicator));
    }

    /**
     * 删除指标信息
     */
    @PreAuthorize("@ss.hasPermi('indicator:indicator:remove')")
    @Log(title = "指标信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{indicatorIds}")
    public AjaxResult remove(@PathVariable Long[] indicatorIds)
    {
        return toAjax(indicatorService.deleteIndicatorByIndicatorIds(indicatorIds));
    }
}
